package code18_design.template;

import java.util.Arrays;

public class Test01 {

	public static void main(String[] args) {
		SortUtil<String> u = new StringSortUtil();
		String[] arr = {"abc", "qw", "x", "12345", "4567"};
		u.sort(arr);
		System.out.println(Arrays.toString(arr));
		
		System.out.println("--------------");
		
		MyComparator<String> mc = new MyComparator<String>() {
			@Override
			public int compare(String t1, String t2) {
				return t1.length() - t2.length();
			}
		};
		SortUtil2.sort(arr, mc);
		System.out.println(Arrays.toString(arr));
	}
	
}
// 使用者 实现剩余逻辑
class StringSortUtil extends SortUtil<String> {
	@Override
	public int compare(String t1, String t2) {
		//return t1.length() - t2.length();
		return t2.length() - t1.length();
	}
}